Socket
Socket
Sign inDemoInstall

any-promise

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

any-promise

Resolve any installed ES6 compatible promise


Version published
Weekly downloads
16M
increased by1.22%
Maintainers
1
Weekly downloads
 
Created

What is any-promise?

The `any-promise` npm package allows you to register and use any ES6-compatible Promise library in a generic way, enabling the use of a preferred promise implementation without being locked into a specific library. This is particularly useful in library code where the developer wants to leave the choice of Promise implementation to the user.

What are any-promise's main functionalities?

Registering a preferred Promise implementation

This code demonstrates how to register Bluebird as the Promise implementation to be used wherever `any-promise` is required. This allows for the use of Bluebird's API and performance benefits in an application or library that abstracts over the specific Promise implementation.

require('any-promise/register/bluebird');
const Promise = require('any-promise');

Using any-promise in a library

This code snippet shows how a library can use `any-promise` to return a Promise from an asynchronous operation without hardcoding a dependency on a specific Promise library. This allows the consumer of the library to choose the Promise implementation.

const Promise = require('any-promise');
module.exports = function asyncOperation() {
  return new Promise(function(resolve, reject) {
    // async operation here
  });
};

Other packages similar to any-promise

Keywords

FAQs

Package last updated on 31 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc